<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
  <script
      src="https://code.jquery.com/jquery-3.6.1.js"
      integrity="sha256-3zlB5s2uwoUzrXK3BT7AX3FyvojsraNFxCc2vC/7pNI="
      crossorigin="anonymous"></script>
  <link rel="stylesheet" type="text/css" th:href="@{/css/butt.css}"/>
  <meta charset="UTF-8">
  <title>Title</title>
  <script type="application/javascript">
    let tex = "";
    let id = "";
    window.addEventListener('mouseup', function (e) {
      if (document.activeElement.tagName === 'TEXTAREA') {
        tex = window.getSelection().toString();
      }
    })

    function next_con() {
      if (tex.length === 0) {
        let isEMpty = confirm("合同没有可选的信息吗？")
        if (!isEMpty) {
          window.location.href = "/begin_mark"
          return
        }
      }

      console.log("日志" + tex)
      $.post("/next", {
        text: tex,
        id: id,
      }, function (data) {
        id = data.id;
        tex = ""
        $("#tar").val(data.text)
      })
    }
    function handle_txt() {
      tex = window.getSelection().toString();
    }
  </script>
</head>
<body>
<form action="upload" method="post" enctype="multipart/form-data">
  <p>批量上传<input type="file" name="file" webkitdirectory directory>
    <input type="submit" th:value="确认">
</form>
<br>
<button class="button" onclick="next_con()">下一个</button>
<br>
<textarea th:id="tar" type="text" rows="300" readonly="readonly" cols="200"
          onmouseup="handle_txt()" th:text="${art}"></textarea>
</body>
</html>